package com.atguigu.dga230315.governance.task;

import com.atguigu.dga230315.governance.service.GovernanceAssessDetailService;
import com.atguigu.dga230315.meta.service.TableMetaInfoService;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AssessScheduleTask {

    @Autowired
    TableMetaInfoService tableMetaInfoService;

    @Autowired
    GovernanceAssessDetailService governanceAssessDetailService;

    @Value("${assess.schemas}")
    String schemaName;

    @Scheduled(cron = "0 41 10 * * *")
    public void assess(){
        String assessDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");


        for (String s : schemaName.split(",")) {
            //提取元数据
            tableMetaInfoService.initMetaInfo(assessDate,s);
        }

        //指标考评 分数
        governanceAssessDetailService.mainAssess(assessDate);

    }
}
